#include <unistd.h>
#include <iostream>
#include "./include/webserver.h"
#include "./include/log/log.h"
int main(int argc, char const *argv[])
{
    if (argc < 1)
    {
        std::cout << "请按如下方式运行程序: ./" << basename(argv[0]) <<"portname\n";
        exit(-1);
    }
    // 获取端口号
    int port = atoi(argv[1]); // atoi: convert string to int
    // 通过终端输入定时器定时时间
    int timeout = -1;
    int triMode = 1;
    int threadNum = 8;
    int logLevel = 1;
    if(argc > 5){ logLevel = atoi(argv[5]); }
    else if(argc > 4){ threadNum = atoi(argv[4]); }
    else if(argc > 3){ triMode = atoi(argv[3]); }
    else if(argc > 2){ timeout = atoi(argv[2]); }
    
    Webserver server(port, timeout, triMode, threadNum, logLevel); // 一般设置 60s 的定时
    server.start();

    return 0;
}
